from api.biz.base.base_info import BaseClientApi


class AddStyleTechniqueSizeApi(BaseClientApi):
    def __init__(self, styleId, versionId, pictureUrl):
        super().__init__()
        self.url = f"{self.host}/styleTechnologySize/save"
        self.method = "post"
        self.json = {"styleId": styleId, "versionId": versionId, "moduleStyle": "TECHNOLOGY_SIZE_TABLE",
                     "sizeStandard": "CN", "informationId": "1788154794101768193", "infoDataJson": {"imageList": [],
                                                                                                    "richText": f"<p>顶顶顶顶</p> <p><img src='{pictureUrl}'>222</p>"},
                     "dimensionalData": [{"part": "前片", "S": 100, "M": 200, "L": 300, "tolerance": 1.23}]}


class StyleTechniqueSizeExportApi(BaseClientApi):
    def __init__(self, styleId, versionId):
        super().__init__()
        self.url = f"{self.host}/styleTechnologySize/export?styleId={styleId}&versionId={versionId}&moduleStyle=TECHNOLOGY_SIZE_TABLE&sizeStandard=CN"
        self.method = "get"


class StyleTechniqueSizeImportApi(BaseClientApi):
    def __init__(self, styleId, versionId, file_path, files):
        super().__init__()
        self.headers = {
            "Authorization": BaseClientApi.auth_token,
            # "Accept":"application/json, text/plain, */*"
        }
        # self.headers["Content-Type"] = "multipart/form-data; boundary=----WebKitFormBoundary7A3emAEIhGe11ktv"
        self.url = f"{self.host}/styleTechnologySize/import?styleId={styleId}&versionId={versionId}&moduleStyle=TECHNOLOGY_SIZE_TABLE&sizeStandard=CN&url={file_path}"
        self.method = "post"
        self.files = files


class StyleTechniqueListApi(BaseClientApi):
    def __init__(self, styleId, versionId, pictureUrl):
        super().__init__()
        self.url = f"{self.host}/styleInformation/saveBatch?versionId={versionId}"
        self.method = "post"
        self.json = [{"styleId": styleId, "versionId": versionId,
                      "moduleType": "TECHNOLOGY_SAMPLE_LIST", "styleModule": "STYLE_MODULE_GY", "deleteFlag": 0,
                      "createTime": "2024-05-08 18:31:40", "createUser": "1771051683642654721", "updateTime": None,
                      "updateUser": None, "dataSources": "DEFAULT", "allowModify": True, "tenantId": "-1",
                      "infoData": "", "infoDataJson": {"imageList": [],
                                                       "richText": f"<p>发的发发发<img src={pictureUrl}></p>",
                                                       "productionType": ""},
                      "extJson": None}]


# class StyleTechniquePhotoImportApi(BaseClientApi):
#     def __init__(self, file_path):
#         super().__init__()
#         self.url = f"{self.dev_host}/file/uploadAliyunReturnUrl"
#         self.method = "post"


class StyleSewingTechniqueApi(BaseClientApi):
    def __init__(self, styleId, versionId, pictureUrl):
        super().__init__()
        self.url = f"{self.host}/styleInformation/saveBatch?versionId={versionId}"
        self.method = "post"
        self.json = [
            {"styleId": styleId, "versionId": versionId, "styleModule": "STYLE_MODULE_GY",
             "moduleType": "PRODUCTION_TYPE_SEWING", "infoDataJson": {"productionType": "PROCESS_TYPE_CF",
                                                                      "imageList": [
                                                                          {"name": "Snipaste_2024-04-16_20-34-39.png",
                                                                           "url": pictureUrl}],
                                                                      "richText": f"<p>顶顶顶顶<img src={pictureUrl}></p>"}},
            {"deleteFlag": 1, "createTime": "2024-05-08 11:31:31", "createUser": "1771046677174599682",
             "updateTime": None, "updateUser": None, "dataSources": "DEFAULT", "allowModify": True, "tenantId": "-1","id":"1788154794122739716",
             "styleId": styleId, "versionId": versionId,
             "styleModule": "STYLE_MODULE_GY", "moduleType": "PRODUCTION_TYPE_SEWING", "infoData": "",
             "infoDataJson": {"imageList": [], "richText": "", "productionType": "PROCESS_TYPE_NC"}, "extJson": None}]
